package org.nViron.nvOrganism;

//~--- non-JDK imports --------------------------------------------------------

import java.util.HashMap;
import java.util.Iterator;

import org.nViron.nvSim.nvObjectMgr;
import org.nViron.nvSim.nvSimulator;

/**
 * Manages organisms, removes dead ones or updates them
 * @author Roland Haring <p>
 * <script type="text/javascript" src="http://www.ohloh.net/p/376434/widgets/project_basic_stats.js"></script>
 */
abstract public class nvOrganismMgr extends nvObjectMgr {
    public nvOrganismMgr(nvSimulator simulator) {
        super(simulator);
    }

    public HashMap getOrganisms() {
        return getObjects();
    }

    @Override
    public void update(float timeStep) {
        for (Iterator i = getOrganisms().values().iterator(); i.hasNext(); ) {
            nvOrganism organism = (nvOrganism) i.next();
            if (organism.getState() == nvStateMgr.DEAD) {
                i.remove();
            } else {
                organism.update(timeStep);
            }
        }
    }
}



